﻿Public Class frmUser

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        UI.FormatDataGrid(dgvuser)
        UI.SetPlaceHolder(txtsearch, "Search User")
        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Private Sub frmUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loaduser()
        formatDgv()
    End Sub

    Private Sub loaduser()
        dgvuser.DataSource = ClassUser.loadUser(txtsearch.Text)
    End Sub

    Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged
        loaduser()
    End Sub

    Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
        Dim frm As New frmNewUser
        If frm.ShowDialog = Windows.Forms.DialogResult.OK Then
            loaduser()
        End If
    End Sub
    Private Sub formatDgv()
        For i = 0 To dgvuser.Rows.Count - 1
            dgvuser.Rows(i).Cells("password").Value = Crypto.Decrypt(dgvuser.Rows(i).Cells("password").Value, 8)
        Next
    End Sub
End Class